package lucene.server.cdc;


import lucene.server.common.dbmeta.DialectUtil;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Properties;

//TIP 要<b>运行</b>代码，请按 <shortcut actionId="Run"/> 或
// 点击装订区域中的 <icon src="AllIcons.Actions.Execute"/> 图标。
public class CDCMain {
    public static void main(String[] args) throws SQLException {
        Properties properties = new Properties();
        properties.setProperty("name", "test");
        properties.setProperty("host", "192.168.1.192");
        properties.setProperty("port", "3306");
        properties.setProperty("type", "mysql");
        properties.setProperty("username", "canal");
        properties.setProperty("password", "Canal@123456");
        properties.setProperty("serverId", "2");
        properties.setProperty("filter", "test,food-supervision.supervisory_base_corpinfo");
        properties.setProperty("poolSize", "10");
        //MysqlBinlogClient mysqlBinlogClient = new MysqlBinlogClient(properties);
        //mysqlBinlogClient.start();
        //Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
        //    @Override
        //    public void run() {
        //        mysqlBinlogClient.shutdown();
        //    }
        //}));
        Connection connection = DialectUtil.getConnection(properties);
        ResultSet resultSet = connection.createStatement().executeQuery("select * from  test.test");
        while (resultSet.next()) {
            System.out.println(resultSet.getTimestamp("f_datetime"));
            System.out.println(resultSet.getTimestamp("f_timestamp"));
        }
    }

}